<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <ui:composition template="template.xhtml">
            <ui:define name="content">
                <p:panel styleClass="panel" header="#{productViewBean.product.name}" style="text-align:center">
                    <h:panelGrid columns="1" style="width:100%">
                        <h:outputText styleClass="fecha" value="#{productViewBean.product.addedOn}">
                            <f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
                        </h:outputText>
                        <h:outputText value="#{productViewBean.product.description}" />
                        <h:outputText styleClass="price" value="#{productViewBean.product.price}">
                            <f:convertNumber currencySymbol="€" type="currency" />
                        </h:outputText>
                        <h:form id="productForm" styleClass="purchaseForm">
                            <h:commandLink onclick="loginPnl.show();" styleClass="accede" value="Accede para comprar"  rendered="#{empty sessionScope.user}"/>
                            <p:spinner id="quantitySp" value="#{productViewBean.quantity}" min="1" max="10" size="2" rendered="#{not empty sessionScope.user}"/>
                            <p:commandButton value="Añadir al carrito" action="#{productViewBean.addToCart}" rendered="#{not empty sessionScope.user}">
                                <f:param name="product" value="#{productViewBean.product.id}" />
                            </p:commandButton>
                        </h:form>
                    </h:panelGrid>
                </p:panel>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

